<?php

namespace App\Admin\Controllers;

use App\Admin\Repositories\SmsBlacklist;
use Dcat\Admin\Form;
use Dcat\Admin\Grid;
use Dcat\Admin\Http\Controllers\AdminController;

class SmsBlacklistController extends AdminController
{
    protected $title="短信黑名单";
    /**
     * Make a grid builder.
     *
     * @return Grid
     */
    protected function grid()
    {
        return Grid::make(new SmsBlacklist(), function (Grid $grid) {
            $grid->model()->orderBy('id', 'desc');
            $grid->column('id')->sortable();
            $grid->column('mobile');
            $grid->column('created_at');
            $grid->filter(function (Grid\Filter $filter) {
                // 展开过滤器
                $filter->expand();
                $filter->panel();
                $filter->equal('mobile','手机号码或邮箱')->width(2);
            });
            //禁用新增按钮
            $grid->disableCreateButton();
            // 禁用过滤器按钮
            $grid->disableFilterButton();
            // 禁用批量删除按钮
            $grid->disableBatchDelete();
            // 禁用显示按钮
            $grid->disableViewButton();
            // 去掉删除
            //$grid->disableDeleteButton();
            $grid->disableEditButton();
            $grid->disableRowSelector();
            //显示横向滚动条
            $grid->scrollbarX();
        });
    }

    /**
     * Make a form builder.
     *
     * @return Form
     */
    protected function form()
    {
        return Form::make(new SmsBlacklist(), function (Form $form) {
            $form->display('id');
            $form->text('mobile');

            $form->display('created_at');
            $form->display('updated_at');
        });
    }
}
